package com.efast.dmom.aps.datahandlers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.dmom.aps.dao.PlanOrderScheduleInfoDao;
import com.efast.dmom.aps.entity.PlanOrderScheduleInfoEntity;
import com.efast.dmom.aps.util.TimeUtil;

@Component
public class PlanOrderScheduleInfoDataHandler {

	@Autowired
	private PlanOrderScheduleInfoDao planOrderScheduleInfoDao;

	public void saveScheduledInfo(List<PlanOrderScheduleInfoEntity> infoList) {
		if (infoList == null) {
			return;
		}
		for (PlanOrderScheduleInfoEntity obj : infoList) {
			obj.setSiteId(DataHandlerUtils.getSiteId());
			obj.setCreationTime(TimeUtil.getLocalDateTime());
			obj.setCreationTimeZone(TimeUtil.getLocalTimeZone());
			obj.setCreator(SpringWebUtils.getRequestUser());
			obj.setLastModifiedTime(TimeUtil.getLocalDateTime());
			obj.setLastModifiedTimeZone(TimeUtil.getLocalTimeZone());
			obj.setLastModifier(SpringWebUtils.getRequestUser());
//			obj.setCreationPid(DataHandlerUtils.getDmomPid());
//			obj.setLastModifiedPid(DataHandlerUtils.getDmomPid());
			obj.setRowStatus(1);
			obj.setRowTrxId(1);
		}
		planOrderScheduleInfoDao.saveScheduledInfo(infoList);
	}

	public void deteleByScheduleDate(List<PlanOrderScheduleInfoEntity> infoList) {
		planOrderScheduleInfoDao.deleteByScheduleDate(infoList);
	}
}
